package com.amkai.aes.webservice.binary.objecthandler;

import java.io.Serializable;
import java.util.List;

import com.amkai.aes.aescommon.service.binary.job.BatchInformationJob;
import com.amkai.aes.aescommon.service.binary.job.Job;
import com.amkai.aes.aescommon.service.result.BatchInformationResult;
import com.amkai.aes.webservice.binary.JobObjectHandler;
import com.amkai.common.extensions.hibernate.config.SiteManager;
import com.amkai.common.extensions.hibernate.config.manager.SessionManager;

public class BatchInformationHandler implements JobObjectHandler<BatchInformationJob, Serializable, BatchInformationResult> {

	@Override
	public BatchInformationResult process(BatchInformationJob job,Serializable object) throws Exception {
		BatchInformationResult result = new BatchInformationResult();
		SessionManager sm = SiteManager.Start();
		
		List<Long> l = sm.execute("FROM Entry e WHERE e.batch=:batch AND e.isActive=true").setEntity("batch", job.getBatch()).list();
		result.setNumberOfTransactions(l.size());
		
		sm.closeSession();
		return result;
	}
}
